package com.topnav.mc.admin.entity.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * 日志类型
 * @Author: kenny
 * @Date: 2024/3/29 16:41
 */

public enum EnumLogType {
    LOGIN(1,"登录","login"),
    LOGOUT(2,"登出","exit"),
    ADD(3,"新增","add"),
    EDIT(4,"修改","modify"),
    DELETE(5,"删除","delete");

    private int code;
    private String desc;
    private String engKey; //多语言使用

    private EnumLogType(Integer code, String desc,String engKey) {
        this.code = code;
        this.desc = desc;
        this.engKey = engKey;
    }

    public int getCode() {return code;}
    public void setCode(int code) {this.code = code;	}
    public String getDesc() {return desc;}
    public void setDesc(String desc) {this.desc = desc;}
    public String getEngKey() {return engKey;}
    public void setengKey(String engKey) {this.engKey = engKey;}


    public static EnumLogType getByCode(int code) {
        for (EnumLogType enumEntity : EnumLogType.values()) {
            if (enumEntity.getCode() == code) {
                return enumEntity;
            }

        }
        return null;
    }
    public static List<EnumModal> toList(){
        List<EnumModal> list = new ArrayList<>();
        for (EnumLogType bean : EnumLogType.values()) {
            EnumModal enumModal = new EnumModal();
            enumModal.setIndex(bean.ordinal());
            enumModal.setCode(bean.getCode());
            enumModal.setName(bean.name());
            enumModal.setDesc(bean.getEngKey());
            list.add(enumModal);
        }
        return list;
    }

}
